using System;
using System.Collections.Generic;
using System.Text;

namespace miciv.Rendering
{
    public class ManagedVertexBuffer<T> where T : struct
    {
        protected VertexBufferManager<T> m_vbManager;
        protected T[] m_vertices;
        protected int m_sVertexCount;
        protected int m_sOffset;
        protected bool m_bIsDirty;

        public T[] Vertices
        {
            get
            {
                return this.m_vertices;
            }
            set
            {
                if (value != this.m_vertices)
                {
                    this.m_vertices = value;
                    this.IsDirty = true;
                }
            }
        }

        public int VertexCount
        {
            get
            {
                return this.m_sVertexCount;
            }
            set
            {
                if (value != this.m_sVertexCount)
                {
                    this.m_sVertexCount = value;
                    this.IsDirty = true;
                }
            }
        }

        public int Offset
        {
            get
            {
                return this.m_sOffset;
            }
            set
            {
                if (value != this.m_sOffset)
                {
                    this.m_sOffset = value;
                    this.IsDirty = true;
                }
            }
        }

        public bool IsDirty
        {
            get
            {
                return this.m_bIsDirty;
            }
            set
            {
                this.m_bIsDirty = value;
                this.m_vbManager.IsDirty |= value;
            }
        }

        public ManagedVertexBuffer(VertexBufferManager<T> _manager)
        {
            this.m_vbManager = _manager;
            this.m_sOffset = -1;
            this.m_sVertexCount = 0;
            this.m_vertices = null;
        }
    }
}
